package com.example.shushiyunsst.fragment.main.home.recycler.provider.advise_provider;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.example.library_common.adapter.multi.JssMultiItemViewHolder;
import com.example.library_common.utils.QMUIDisplayHelper;
import com.example.shushiyunsst.R;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.advise_bean.AdviseH5Entity;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.advise_bean.AdviseImgEntity;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.advise_bean.AdviseVideoEntity;
import com.example.wallet.global.AppGlobals;

public class AdviseImgProvider extends JssMultiItemViewHolder<AdviseImgEntity> {

    private final int height;

    public AdviseImgProvider(View view) {
        super(view);
        int screenWidth = QMUIDisplayHelper.getScreenWidth(AppGlobals.getApplication());
        height = screenWidth / 4;
    }

    @Override
    public int getItemLayout() {
        return R.layout.advise_img_provider_layout;
    }

    @Override
    public void convert(Context context, AdviseImgEntity mEntity) {
        super.convert(context, mEntity);
        View view = findView(R.id.frame);
        if (view !=null){
            ViewGroup.LayoutParams lp = view.getLayoutParams();
            if (lp != null && lp.height != height) {
                lp.height = height;
                view.setLayoutParams(lp);
            }
        }
        setImageNetUrl(R.id.img,mEntity.getModUrl(),R.drawable.img_erros_bg_rect);
    }

}
